package com.springboot.erp.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.springboot.erp.common.CommonResult;
import com.springboot.erp.entity.JshDepot;
import com.springboot.erp.service.JshDepotService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RequestMapping("/JshDepotService")
@RestController
@Slf4j
public class JshDepotController {
    @Resource
    private JshDepotService jshDepotService;
    @GetMapping("/queryForPages")
    public Page<JshDepot> queryForPages(@RequestParam (required = false) String name,
                                        @RequestParam (required = false)String remark,
                                        @RequestParam (required = false,defaultValue = "1")int current,
                                        @RequestParam (required = false,defaultValue = "5")int size,
                                        @RequestParam (required = false,defaultValue = "id")String orderBy,
                                        @RequestParam (required = false,defaultValue = "true")boolean asc){
        return jshDepotService.selectForPagesDI(name, remark, current, size, orderBy, asc);
    }
    @PostMapping("/addOne")
    public CommonResult addOne(@RequestBody JshDepot jshDepot){
        jshDepotService.addOne(jshDepot);
        log.info("addOne");
        return new CommonResult(200,"success", null);
    }
    @PutMapping("/updateOne")
    public CommonResult updateOne(@RequestBody JshDepot jshDepot){
        jshDepotService.updateOne(jshDepot);
        log.info("updateOne");
        return new CommonResult(200,"success", null);
    }
    @DeleteMapping("/deleteOne")
    public CommonResult deleteOne(@RequestParam Integer id){
        jshDepotService.deleteOne(id);
        log.info("deleteOne");
        return new CommonResult(200,"success", null);
    }
}
